Namespace definitions

Since

0.14.14

Types

Link copied to clipboard
type format

A time formatter type for formatting and parsing UTC dates and times. A rell.time.format value is constructed from format pattern text. The resulting value can then be used to format a unix timestamp according to the format pattern text, or the inverse, i.e. to parse a timestamp from text that is formatted according to the format pattern text, returning a unix timestamp.

The following format specifiers are supported:

SpecifierMeaning
yYear
MMonth in the year
wWeek in the year
WWeek in the month
DDay in the year
dDay in the month
EDay name in the week
uDay number in the week
aAM/PM specifier
HHour in the day (0-23)
hHour in the am/pm (1-12)
mMinute in the hour
sSecond in the minute
SMilliseconds in the second

Non-interpreted text may be included within 'single quotes'. A single quote is escaped with a second single quote (i.e. '').

Examples:

rell.time.format('yyyy.MM.dd \'at\' HH:mm:ss').text_to_ms('2001.07.04 at 11:08:56') // returns 994244936000
rell.time.format('EEE, MMM d, \'\'yy').text_to_ms('Wed, Jul 4, \'01') // returns 994204800000
rell.time.format('h:mm a').text_to_ms('11:08 AM') // returns 40080000
rell.time.format('hh \'o\'\'clock\' a').text_to_ms('11 o\'clock AM') // returns 39600000

val ms: integer = 994244936235;
rell.time.format('hh:mm a').ms_to_text(ms) // returns '11:08 AM'
rell.time.format('yyyyy.MMMMM.dd hh:mm aaa').ms_to_text(ms) // returns '02001.July.04 11:08 AM'
rell.time.format('yyyy-MM-dd\'T\'HH:mm:ss.SSS').ms_to_text(ms) // returns '2001-07-04T11:08:56.235'
rell.time.format('yyyy-\'W\'ww-u').ms_to_text(ms) // returns '2001-W27-3'

Functions

Link copied to clipboard
function ms_to_text(pattern: text, ms: integer): text

Format a unix timestamp according to the given time format text.

Equivalent to rell.time.format(pattern).ms_to_text(ms).

Link copied to clipboard
function text_to_ms(pattern: text, text: text): integer

Parse a unix timestamp from text formatted according to the given time format pattern text.

Equivalent to rell.time.format(pattern).text_to_ms(text).

Link copied to clipboard
function text_to_ms_or_null(pattern: text, text: text): integer?

Parse a unix timestamp from text formatted according to the given time format pattern text.

Equivalent to rell.time.format(pattern).text_to_ms_or_null(text).